<?php
/**
 * TomatoCMS
 *
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 *
 * @copyright    Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license        http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version     $Id: add.phtml 3032 2010-05-25 08:00:42Z huuphuoc $
 */
?>
<?php
$this->headTitle($this->translator('product_choose_attribute_page_title'));
$this->headScript()->appendFile($this->APP_STATIC_SERVER.'/js/jquery.validate/jquery.validate.min.js');
?>

<div class="grid_12 t_a_ui_breadcrumb">
    <span><a href="<?php echo $this->url(array(), 'shop_product_list'); ?>"><?php echo $this->translator('product_list_breadcump'); ?></a></span>
    <span><a href="<?php echo $this->url(array('product_id' => $this->product_id), 'shop_product_edit'); ?>"><?php echo $this->translator('product_edit_breadcump'); ?></a></span>
    <span><?php echo $this->translator('product_choose_attribute_breadcump'); ?></span>
</div>

<div class="grid_12"><?php echo $this->flashMessenger(); ?></div>
<form method="post" action="<?php echo $this->url(array('product_id' => $this->product_id), 'shop_product_choose_attribute'); ?>" id="addProductForm">
<div class="grid_12 t_a_bottom">
    <div class="prefix_1 suffix_1">
        <?php /*<div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('product_category'); ?>:</label>
            <div style="border:1px solid #CCC; padding: 5px; width:300px;overflow:auto;height:120px">
                <?php for ($i = 0; $i < count($this->categories); $i++) : ?>
                <input class="category_checkbox" type="checkbox" <?php if(strstr($this->strCategoryId,",{$this->categories[$i]->category_id},")){echo 'checked';}?> id="category_id[]" name="category_id[]" value="<?php echo $this->categories[$i]->category_id; ?>"> <?php echo str_repeat('---', $this->categories[$i]->depth).$this->categories[$i]->category_admin_name; ?><br>
                <?php endfor; ?>
            </div>
            <label>&nbsp;</label>
            <button type="button" id="choose_attribute"><span><?php echo $this->translator('product_button_choose_attribute'); ?></span></button>
        </div>*/?>

        <div id="attributeList"></div>

        <hr/>

        <div class="clearfix t_a_bottom">
            <label>&nbsp;</label>
            <button type="submit"><span><?php echo $this->translator('product_add_save_button'); ?></span></button>
        </div>
    </div>
</div>
</form>
<div class="grid_12">
    <hr/>
    <?php echo $this->translator('product_attribute_guide'); ?><br>
    <a class="t_a_ui_button_link" href="<?php echo $this->url(array('product_id' => $this->product_id), 'shop_product_attribute_value'); ?>"><span><?php echo $this->translator('product_attribute_value'); ?></span></a>
</div>

<script type="text/javascript">
$(document).ready(function() {
    /*$("#choose_attribute").bind('click', function(){
        var strCategory_id = '';
        $('.category_checkbox:checked').each(function()    {
            var value = $(this).val();
            strCategory_id += value+',';
        });
        $.ajax({
            url: "<?php echo $this->url(array(), 'shop_product_get_attribute'); ?>",
            method : "POST",
            data: {strCategory_id : strCategory_id, strAttributeTypeId: '<?php echo $this->strAttributeTypeId;?>'},
            success: function(html){
                $('#attributeList').html(html);
            }
        });
    });*/

    /*var strCategory_id = '';
    $('.category_checkbox:checked').each(function()    {
        var value = $(this).val();
        strCategory_id += value+',';
    });*/

    var strCategory_id = '<?php echo $this->strCat;?>';
    $("#attributeList").html('').addClass('t_a_ui_helper_loading');
    $.ajax({
        url: "<?php echo $this->url(array(), 'shop_product_get_attribute'); ?>",
        method : "POST",
        data: {strCategory_id : strCategory_id, strAttributeTypeId: '<?php echo $this->strAttributeTypeId;?>'},
        success: function(html){
            $("#attributeList").html('').removeClass('t_a_ui_helper_loading');
            $('#attributeList').html(html);
        }
    });
});
</script>
